package com.edu.exam.entity.assessment.technical;

import com.edu.exam.enums.assessment.technical.*;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.time.LocalDateTime;

/**
 * 试卷相似度结果实体类
 * 所属模块：B-02 题库管理模块
 * 对应数据库表：question_paper_similarity_result
 *
 * 根据B-03-10试卷查重子模块设计文档实现
 * 存储试卷间详细的相似度分析结果，包含多维度相似度分析和详细的算法执行信息。
 *
 * @author System
 * @version 1.0.0
 */

@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class QuestionPaperSimilarityResult {

    /**
     * 主键ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 查重记录ID
     */
    @Column(name = "record_id", nullable = false)
    private Long recordId;

    /**
     * 源试卷ID
     */
    @Column(name = "source_paper_id", nullable = false)
    private Long sourcePaperId;

    /**
     * 目标试卷ID
     */
    @Column(name = "target_paper_id", nullable = false)
    private Long targetPaperId;

    /**
     * 目标试卷标题
     */
    @Column(name = "target_paper_title", length = 200)
    private String targetPaperTitle;

    /**
     * 最终相似度评分
     */
    @Column(name = "final_similarity", precision = 5, scale = 4)
    private Double finalSimilarity;

    /**
     * 相似度等级
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "similarity_level", length = 20)
    private SimilarityLevel similarityLevel;

    /**
     * 试题级相似度
     */
    @Column(name = "question_similarity", precision = 5, scale = 4)
    private Double questionSimilarity;

    /**
     * 试卷级相似度
     */
    @Column(name = "paper_similarity", precision = 5, scale = 4)
    private Double paperSimilarity;

    /**
     * 文本相似度
     */
    @Column(name = "text_similarity", precision = 5, scale = 4)
    private Double textSimilarity;

    /**
     * 语义相似度
     */
    @Column(name = "semantic_similarity", precision = 5, scale = 4)
    private Double semanticSimilarity;

    /**
     * 结构相似度
     */
    @Column(name = "structure_similarity", precision = 5, scale = 4)
    private Double structureSimilarity;

    /**
     * 难度分布相似度
     */
    @Column(name = "difficulty_similarity", precision = 5, scale = 4)
    private Double difficultySimilarity;

    /**
     * 题型分布相似度
     */
    @Column(name = "type_similarity", precision = 5, scale = 4)
    private Double typeSimilarity;

    /**
     * 知识点相似度
     */
    @Column(name = "knowledge_similarity", precision = 5, scale = 4)
    private Double knowledgeSimilarity;

    /**
     * 维度权重配置信息（JSON格式存储）
     */
    @Column(name = "dimension_weights", columnDefinition = "TEXT")
    private String dimensionWeights;

    /**
     * 算法执行详细参数（JSON格式存储）
     */
    @Column(name = "algorithm_details", columnDefinition = "TEXT")
    private String algorithmDetails;

    /**
     * 重复试题数量
     */
    @Column(name = "repeated_question_count")
    private Integer repeatedQuestionCount;

    /**
     * 重复试题比例
     */
    @Column(name = "repeated_question_rate", precision = 5, scale = 4)
    private Double repeatedQuestionRate;

    /**
     * 源试卷试题总数
     */
    @Column(name = "total_questions_source")
    private Integer totalQuestionsSource;

    /**
     * 目标试卷试题总数
     */
    @Column(name = "total_questions_target")
    private Integer totalQuestionsTarget;

    /**
     * 综合相似度评分
     */
    @Column(name = "similarity_score", precision = 5, scale = 4)
    private Double similarityScore;

    /**
     * 结果置信度
     */
    @Column(name = "confidence_level", precision = 5, scale = 4)
    private Double confidenceLevel;

    /**
     * 分析耗时（毫秒）
     */
    @Column(name = "analysis_time")
    private Long analysisTime;

    /**
     * 创建时间
     */
    @CreationTimestamp
    @Column(name = "create_time", nullable = false, updatable = false)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @UpdateTimestamp
    @Column(name = "update_time")
    private LocalDateTime updateTime;

    /**
     * 版本号（用于乐观锁）
     */
    @Version
    @Column(name = "version", nullable = false)
    private Long version = 0L;

    /**
     * 是否删除
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted = false;
}